package com.geofitti.andoird;

import org.json.JSONException;
import org.json.JSONObject;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Base64;
import android.widget.ImageView;

public class PictureView extends Activity {
	//public ImageView someview;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.picture_view);
        ImageView someview = (ImageView) findViewById(R.id.test_image);
        
        Bundle extras = getIntent().getExtras();
        String imgStr = extras.getString("dbImage");
        byte[] decodedString;
        decodedString = Base64.decode(imgStr, Base64.DEFAULT);
        Bitmap someimg = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
        someview.setImageBitmap(someimg);
    }
    
    public void setImage(Bitmap dbImage){
    	
//setContentView(R.layout.picture_view);
//this.someview = (ImageView) findViewById(R.id.test_image);
    //	someview.setBackgroundColor(Color.RED);
        
//        JSONObject jsonO;
//        try {
//            jsonO = WebCall.doGet("http://icarus.cs.weber.edu/~km06559/geofitti.php/getImage");
//            final String status = jsonO.getString("status");
//           
//            byte[] decodedString;
//            decodedString = Base64.decode(jsonO.getString("photo"), Base64.DEFAULT);
//            Bitmap someimg = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length);
//            someview.setImageBitmap(someimg);
//           
//        } catch (JSONException e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
    }
}


//not sure waht to do with this yet
//http://www.higherpass.com/Android/Tutorials/Working-With-Images-In-Android/